jQuery.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
		{
			return {
				"iStart":         oSettings._iDisplayStart,
				"iEnd":           oSettings.fnDisplayEnd(),
				"iLength":        oSettings._iDisplayLength,
				"iTotal":         oSettings.fnRecordsTotal(),
				"iFilteredTotal": oSettings.fnRecordsDisplay(),
				"iPage":          oSettings._iDisplayLength === -1 ?
					0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
				"iTotalPages":    oSettings._iDisplayLength === -1 ?
					0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
			};
		};

	
	function dataTable(data,path) {
		var oLanguage = data.split(",");

		$("#updatePicture").hide();
		$("#applicationdata").dataTable( {
			"bJQueryUI": true,
			"sPaginationType": "full_numbers",
			"oLanguage": {
	            "oPaginate": {
	                          "sFirst": oLanguage[0],// ปุ่มกลับมาหน้าแรก
	                          "sLast": oLanguage[1],//ปุ่มไปหน้าสุดท้าย
	                          "sNext": oLanguage[2], //ปุ่มหน้าถัดไป
	                          "sPrevious": oLanguage[3] // ปุ่ม กลับ
	                        	  },
	             "sLengthMenu": oLanguage[4],  
	             "sZeroRecords": oLanguage[5], 
	             "sInfo": oLanguage[6],
	             "sEmptyTable": oLanguage[7],
	             "sLoadingRecords": oLanguage[8],
	             "sProcessing": oLanguage[9],
	             "sInfoEmpty": oLanguage[10],
	             "sInfoFiltered": oLanguage[11]
	        },
			"fnRowCallback" : function(nRow, aData, iDisplayIndex){
                $("td:first", nRow).html(iDisplayIndex +1);
               return nRow;
            },
	        "bProcessing": true,
//	        "bServerSide": true,
//	        "sort": "position",
	        
	        "bStateSave": false,
	        "iDisplayLength": 10,
	        "iDisplayStart": 0,
	        "fnDrawCallback": function () {   
	        },         
	        "sAjaxSource": "application/applicationDataTables",
	        "aoColumns": [
				{ "mData": null,sClass: "center", sWidth: '5%'},
				{ "mData": "vaApplicationId",sClass: "left", sWidth: '5%' },
				{ "mData": "vaApplicationName",sClass: "left", sWidth: '20%'  },
				{ "mData": null,"mRender": function ( data, type, full ) {
				    return "<img src='"+path+"/resources/images/"+full.vaImageUrl+"' height='100' width='100'>";
				    }
				, sWidth: '10%',sClass: "center"},
				{ "mData": "vaLink",sClass: "left", sWidth: '10%' },
				{ "mData": null,"mRender": function ( data, type, full ) {
					if(full.vaMenuStatus=='N'){
						return "<i class='fa fa-times' style='color: coral'></i>";
					} else {
						return "<i class='fa fa-check' style='color: lawngreen'></i>";
					}
				    
			    	}
				,sClass: "center", sWidth: '5%' },
				{ "mData": null,"mRender": function ( data, type, full ) {
					var poObject = [full.vaApplicationId,full.vaApplicationName,full.vaImageUrl,full.vaLink];
					
				    return "<button onclick=\"manageData('"+full.vaApplicationId+"','"+full.vaApplicationName+"')\" class='btn btn-default btn-sm'><i class='fa fa-file-text-o'></i></button><button onclick=\"editData('"+poObject+"')\" class='btn btn-info btn-sm'><i class='fa fa-edit'></i></button>"+
		    		"<button onclick=\"deleteData('"+full.vaApplicationId+"')\" class='btn btn-warning btn-sm'><i class='fa fa-trash-o'></i></button>";
				    }
				, sWidth: '10%',sClass: "center"},
	        ]} 
		);
		
		$('#chk-all').click(function()	{
			if($(this).is(':checked'))	{
				$('#responsiveTable').find('.chk-row').each(function()	{
					$(this).prop('checked', true);
					$(this).parent().parent().parent().addClass('selected');
				});
			}
			else	{
				$('#responsiveTable').find('.chk-row').each(function()	{
					$(this).prop('checked' , false);
					$(this).parent().parent().parent().removeClass('selected');
				});
			}
		});
	}
	
	function manageData(vaApplicationId,vaApplicationName){
		window.location.href = "menu?vaApplicationId="+vaApplicationId+"&vaApplicationName="+vaApplicationName;
	}
	
	function editData(data){
		var paApplication = data.split(",");
		
		$('#uploadImg').prop('checked', false);
		$("#vaImage").hide();
		$("#input-group *").attr("disabled", "disabled").off('click');
		$(".kv-fileinput-caption").css("background-color", "rgb(238, 238, 238)");
		$(".btn-file").css("background-color", "rgb(238, 238, 238)");
		$("#vaApplicationId").hide();
		$("#vaApplicationId").val(paApplication[0]);
		$("#updateApplicationId").show();
		$("#updateApplicationId").val(paApplication[0]);
		$("#updateApplicationId").prop('disabled', true);
		$("#vaApplicationName").val(paApplication[1]);
		$("#updatePicture").show();
		$("#vaImageUrl").val(paApplication[2]);
		$("#vaLink").val(paApplication[3]);
		$("#processType").val("update");
		$("#uploadImgTemp").val("no");
		$("#vaImageUrl").val(null);
	}
	
	function deleteData(data){
		$("#vaApplicationId").hide();
		$("#vaApplicationId").val(data);
		$("#updateApplicationId").show();
		$("#processType").val("delete");
		document.getElementById('application').submit();
		
	}
	
	function clears(){
		$("#vaImage").show();
		$("#input-group *").removeAttr("disabled");
		$("#vaApplicationId").show();
		$("#vaApplicationId").val("");
		$("#updateApplicationId").hide();
		$("#updatePicture").hide();
		$("#vaApplicationName").val("");
		$("#vaImage").prop('disabled', false);
		$("#vaImageUrl").val("");
		$("#vaLink").val("");
		$(".kv-fileinput-caption").css("background-color", "rgb(255, 255, 255)");
		$(".btn-file").css("background-color", "rgb(255, 255, 255)");
		$("#uploadImgTemp").val("");
		$("#processType").val("input");
	}
	
    $("#vaImage").fileinput({
        'allowedFileExtensions' : ['jpg', 'png','gif'],
    });
    
    function uploadImage(){
    	if($('#uploadImg').is(':checked')){
    		$("#input-group *").removeAttr("disabled");
        	$(".kv-fileinput-caption").css("background-color", "rgb(255, 255, 255)");
    		$(".btn-file").css("background-color", "rgb(255, 255, 255)");
    		$("#uploadImgTemp").val("yes");
    		$("#vaImage").show();
    	}else{	
    		$("#input-group *").attr("disabled", "disabled").off('click');
    		$(".kv-fileinput-caption").css("background-color", "rgb(238, 238, 238)");
    		$(".btn-file").css("background-color", "rgb(238, 238, 238)");
    		$("#uploadImgTemp").val("no");
    		$("#vaImage").hide();
    	}
    	
    }